package com.olap.starter.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.olap.starter.core.base.BaseService;
import com.olap.starter.mapper.TableToolButMapper;
import com.olap.starter.pojo.TableConfig;
import com.olap.starter.pojo.TableToolBut;
import com.olap.starter.pojo.TreeConfig;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author WBG
 * @since 2022-08-31
 */
@Service
@DS("online")
public class TableToolButServices extends BaseService<TableToolButMapper,TableToolBut> {


    public void saveList(List<TableToolBut> toolBut, TableConfig tableConfig) {
        if(toolBut == null){
            return;
        }
        for (TableToolBut tableToolBut : toolBut) {
            tableToolBut.setParentId(tableConfig.getId());
            tableToolBut.setVersion(tableConfig.getVersion());
            tableToolBut.setId(null);
            tableToolBut.setType("0");
            save(tableToolBut);
        }
    }
    public void saveList(List<TableToolBut> toolBut, TreeConfig treeConfig) {
        if(toolBut == null){
            return;
        }
        for (TableToolBut tableToolBut : toolBut) {
            tableToolBut.setParentId(treeConfig.getId());
            tableToolBut.setId(null);
            tableToolBut.setVersion(treeConfig.getVersion());
            tableToolBut.setType("1");
            save(tableToolBut);
        }
    }
}
